async function playDaXiao() {
    write('您来到了逍遥楼赌坊~');
    // 变换背景
    DrawBackgroundImage("img/daxiao.jpg");
    // 播放音乐
    playMusic('mp3/bg.mp3', true, true);
    setVolume(0.05);
    yaoSaizi();
}
var a = 0, b = 0, c = 0; // 用于记录三颗色子的随机数
var maidinglishouBtn = null; // 买定离手的按钮
async function yaoSaizi() {
    // 画图片
    DrawImage('img/p1.png', 390, 100)
    // 摇色子
    playMusic('mp3/saizi.mp3', true, false);// 自动播放 不要循环
    write('准备开始了')
    await sleep(1000);
    a = getNumber();
    b = getNumber();
    c = getNumber();
    // 开始买大小了
    maidinglishouBtn = write(`
        <button onclick="kaijiang('da')">买大</button>
        <button onclick="kaijiang('xiao')">买小</button>
    `, true);
}
// 开奖
async function kaijiang(type){ 
    
    maidinglishouBtn.delete(); // 删除买大小的按钮
    playMusic('mp3/maidinglishou.mp3',true,false);
    await sleep(2000)
    await write('开~~~~~',true)
    await sleep(1000)
    console.log(a,b,c)
    var sum = a + b + c;
    await write(`
        <span class="sz">`+a+`</span>
        <span class="sz">`+b+`</span>
        <span class="sz">`+c+`</span>
    `)
    // 判断是否赢
    if(a == b && b == c){
        await write('豹子通杀',true);
        await sleep(1000);
        qian -= 100;
        await write('恭喜你赌输了,现有金钱:' + qian,true);
    }else if(sum > 9){ // 开大
        await write('大',true)
        if(type == 'da'){ // 开大买大
            qian += 100;
            await write('真不好意思居然赢了,现有金钱:' + qian,true);
        }else{
            qian -= 100;
            await write('恭喜你赌输了,现有金钱:' + qian,true);
        }
    }else{
        write('小',true)
        if(type == 'xiao'){ // 开小买小
            qian += 100;
            await write('真不好意思居然赢了,现有金钱:' + qian,true);
        }else{
            qian -= 100;
            await write('恭喜你赌输了,现有金钱:' + qian,true);
        }
    }
    await write('作为一个职业赌徒要继续吗?',true)
    maidinglishouBtn = write(`
        <button onclick="yaoSaizi()">继续</button>
        <button>算了我要去与乞丐一起玩了</button>
    `, true);
}

function getNumber() {
    // 1 2 3 4 5 6
    var n = Math.random(); // 0 ~ 0.999
    n = n * 6; // 0 ~ 5.9999
    n = parseInt(n); // 0,1,2,3,4,5
    return n + 1;
}